import java.util.ArrayList;
import java.util.List;

/**
 * @author LKQ
 * @date 2022/2/15 10:11
 * @description 遍历
 */
public class Solution {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int[][] matrix = {{3, 7, 8}, {9, 11, 13}, {15, 16, 17}};
        solution.luckyNumbers(matrix);
    }
    public List<Integer> luckyNumbers (int[][] matrix) {
        ArrayList<Integer> integers = new ArrayList<>();
        int n = matrix[0].length;
        for (int[] ints : matrix) {
            int min = 100001;
            int column = 0;
            // 首先找到一行中最小的数
            for (int j = 0; j < n; j++) {
                if (ints[j] < min) {
                    min = ints[j];
                    column = j;
                }
            }
            boolean max = true;
            for (int[] value : matrix) {
                if (value[column] > min) {
                    // 同一列中不是最大
                    max = false;
                    break;
                }
            }
            if (max) {
                integers.add(min);
            }

        }
        return integers;
    }
}
